/**
 * 
 */
package com.agilegroup.crm.adapters;

import java.util.List;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.agilegroup.crm.R;
import com.agilegroup.crm.model.Spinner;

/**
 * @author hisham
 *
 */
public class SpinnerAdapter extends ArrayAdapter<Spinner>{

	private Activity activity;
	private List<Spinner>spinnerData;
	
	public SpinnerAdapter(Activity activity, int textViewResourceId,List<Spinner>spinnerData) {
		super(activity, textViewResourceId, spinnerData);
		this.activity=activity;
		this.spinnerData=spinnerData;
	}
	
	public View getCustomView(int position, View convertView,ViewGroup parent) {
		LayoutInflater inflater = activity.getLayoutInflater();
		View customLayout = inflater.inflate(com.agilegroup.crm.R.layout.spinner_row, parent, false);
		
		TextView txtId = (TextView)customLayout.findViewById(R.id.txtId);
		TextView txtName = (TextView) customLayout.findViewById(R.id.txtName);
		//CallDetails callDetails = callDetailsList.get(position);
		Spinner spinner = spinnerData.get(position);
		txtId.setText(spinner.getId());
		txtName.setText(spinner.getName());
		
		return customLayout;
	}
	@Override
	public View getDropDownView(int position, View convertView,ViewGroup parent) {
		return getCustomView(position, convertView, parent);
	}
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		return getCustomView(position, convertView, parent);
	}
	
}
